package com.zgjkhis.modules.charges.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @Author yzq
 * @Description 附加费用
 * @Date 2021/6/23 9:38
 * @Param
 * @return
 **/
@Data
@TableName("his_prescription_charge")
public class PrescriptionCharge implements Serializable {

    @TableId
    private Long id;
    @ApiModelProperty(value = "收费类型1：材料费用，2：检验检查，3：治疗项目，4：其他费用")
    @NotNull(message = "收费类型不能为空")
    @Range(min = 1,max = 4,message = "收费类型错误")
    private Integer type;
    @ApiModelProperty(value = "项目名称")
    private String projectName;
    @ApiModelProperty(value = "项目id")
    @NotNull(message = "项目id不能为空")
    private String projectId;
    @ApiModelProperty(value = "规格")
    private String spec;
    @ApiModelProperty(value = "数量")
    @NotNull(message = "数量不能为空")
    private Integer quantity;
    @ApiModelProperty(value = "单价")
    private BigDecimal price;
    @ApiModelProperty(value = "单位")
    private String useUnit;
    @ApiModelProperty(value = "折扣")
    private String discount;
    @ApiModelProperty(value = "折扣金额")
    private BigDecimal discountPrice;
    @ApiModelProperty(value = "总金额")
    private BigDecimal totalPrice;
    @ApiModelProperty(value = "状态0：未支付，1：已支付，2部分退款，3已退款")
    private Integer status;
    @ApiModelProperty(value = "已退个数")
    private Integer refundCount;
    @ApiModelProperty(value = "订单号")
    private String orderNo;

    /** 创建时间 */
    @TableField(fill= FieldFill.INSERT)
    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date createTime;
    @ApiModelProperty(value = "药房id")
    private String pharmacyId;

    public void copy(PrescriptionCharge source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
